package site.marqstree.latte.ec.main.discover;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import me.yokeyword.fragmentation.anim.DefaultHorizontalAnimator;
import me.yokeyword.fragmentation.anim.FragmentAnimator;
import site.marqstree.latte.core.delegates.bottom.BottomItemDelegate;
import site.marqstree.latte.core.delegates.web.WebDelegateImpl;
import site.marqstree.latte.ec.R;

/*
 * 项目名: EleCommerce
 * 包名: site.marqstree.latte.ec.main.discover
 * 文件名: DiscoverDelegate
 * 创建者: marqstree
 * 创建时间: 2020/1/30 12:42
 * 描述: TODO
 */
public class DiscoverDelegate extends BottomItemDelegate {

    @Override
    public Object setLayout() {
        return R.layout.delegate_discover;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, @NonNull View rootView) {

    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        final WebDelegateImpl delegate = WebDelegateImpl.create("index1.html");
        //final WebDelegateImpl delegate = WebDelegateImpl.create("https://www.douban.com");
        //传入Discover Tab页的父Fragment(带Tab导航按钮的Fragment)
        delegate.setTopDelegate(this.getParentDelegate());
        //将带WebView的Fragment填充入容器(R.id.web_disco
        // very_container)
        getSupportDelegate().loadRootFragment(R.id.web_discovery_container, delegate);
    }

    @Override
    public FragmentAnimator onCreateFragmentAnimator() {
        return new DefaultHorizontalAnimator();
    }
}
